package com.lanchewuyou.user.driver.layouts;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.lanchewuyou.user.driver.R;


/**
 * 易理赔车内物品列表项自定义控件
 */
public class RadioBtnLayout extends LinearLayout {
    private TextView titleText;
    private RadioGroup radioGroup;
    private RadioButton radioBtn1, radioBtn2;
    String checkId = "1";


    public RadioBtnLayout(Context context) {
        super(context);
    }

    public RadioBtnLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.radio_layout, this);
        titleText = (TextView) findViewById(R.id.radio_title_text);
        radioGroup = (RadioGroup) findViewById(R.id.radiogroup);
        radioBtn1 = (RadioButton) findViewById(R.id.radio_btn_yes);
        radioBtn2 = (RadioButton) findViewById(R.id.radio_btn_no);
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.radio_btn_yes:
                        checkId = "1";
                        break;
                    case R.id.radio_btn_no:
                        checkId = "2";
                        break;
                    default:
                        break;
                }
            }
        });

    }

    public void setTitleText(String title) {
        titleText.setText(title);
    }

    public String getCheckId() {
        return checkId;
    }

    public void setRadioText() {
        radioBtn1.setText("一");
        radioBtn2.setText("二");
    }
}
